<template>
	<view class="new">
		<view class="top">
			<view class="text">
				<text :class="{black:iscolr,grey:!iscolr}" @click="change">新碟</text>
				<text class="biaoji"> | </text>
				<text :class="{black:!iscolr,grey:iscolr}" @click="change">新歌</text>
			</view>
			<view class="qiehuan" @click="jump">
				{{name}}
			</view>
		</view>
		<!-- 新碟 -->
		<view class="bottom" v-if="show">
			<view class="inside" v-for="item in albums" :key="item.id">
				<view class="img">
					<!--  #ifdef  MP-WEIXIN -->
					<image :src="item.picUrl"></image>
					<!--  #endif -->
					<!--  #ifndef  MP-WEIXIN -->
					<img  v-lazy="item.picUrl">
					<!--  #endif -->
				</view>
				<p class="title">{{item.name}}</p>
				<p class="contanct">{{item.artist.name}}</p>
			</view>
		</view>
		<!-- 新歌 -->
		<view class="bottom" v-else>
			<view class="inside" v-for="item in sing" :key="item.id" @click="leave(item.id)">
				<view class="img">
					<!--  #ifdef  MP-WEIXIN -->
					<image :src="item.album.blurPicUrl"></image>
					<!--  #endif -->
					<!--  #ifndef  MP-WEIXIN -->
					<img  v-lazy="item.album.blurPicUrl">
					<!--  #endif -->
					
					
				</view>
				<p class="title">{{item.name}}</p>
				<p class="contanct">{{item.artists[0].name}}</p>
			</view>
		</view>
	</view>
</template>

<script>
	import {newest,song} from '../../api/tuijian/tuijian.js'
	export default {
		created() {
			newest().then(res => {
				this.albums.push(res.albums[0])
				this.albums.push(res.albums[1])
				this.albums.push(res.albums[2])
			})
			song({type:0}).then(res => {
				this.sing.push(res.data[0])
				this.sing.push(res.data[1])
				this.sing.push(res.data[2])
			})
		},
		data() {
			return {
				iscolr:true,
				name:'更多新碟',
				albums:[],
				show:true,
				sing:[]
			}
		},
		methods:{
			leave(id){
				uni.navigateTo({
					url:'../../BoFangQi/BoFangQi?id=' + id
				})
			},
			change(){
				this.iscolr = !this.iscolr
				this.show = !this.show
				if(this.name === '更多新碟'){
					this.name = '新歌推荐'
				}else{
					this.name = '更多新碟'
				}
			},
			jump(){
				if(this.name === '更多新碟'){
					return
				}else{
					uni.navigateTo({
						url:'../../newSingtuiJian/newSingtuiJian'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.new{
		width: 100%;
		margin-top: 80rpx;
		// background-color: red;
		.top{
			width: 100%;
			height: 60rpx;
			display: flex;
			//background-color: green;
			align-items: center;
			.text{
				margin-left: 20rpx;
				.black{
					font-size: 34rpx;
					font-weight: 400;
				}
				.biaoji{
					margin-left: 10rpx;
					margin-right: 10rpx;
					color: #8a8a8a;
				}
				.grey{
					font-size: 28rpx;
					color: #8a8a8a;
					font-weight: 400;
				}
			}
			.qiehuan{
				font-size: 28rpx;
				margin-top: 10rpx;
				margin-left: 420rpx;
			}
		}
		.bottom{
			width: 100%;
			height: 200rpx;
			//background-color: red;
			display: flex;
			justify-content: space-around;
			.inside{
				height: 100%;
				width: 30%;
				//background-color: yellow;
				.img{
					width: 130rpx;
					height: 130rpx;
					margin: auto;
					/*  #ifdef  MP-WEIXIN  */
					image{
						width: 100%;
						height: 100%;
					}
					/*  #endif  */
					/*  #ifndef  MP-WEIXIN  */
					img{
						width: 100%;
						height: 100%;
					}
					/*  #endif  */
					
				}
				.title{
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					word-break: normal;
					font-size: 28rpx;
					font-weight: 400;
					margin-left: 46rpx;
				}
				.contanct{
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					word-break: normal;
					font-size: 24rpx;
					font-weight: 400;
					margin-left: 46rpx;
					color: #888;
				}
			}
		}
	}
</style>
